import { createI18n } from 'vue-i18n'
import elementEnLocale from 'element-plus/dist/locale/en'
import elementZnLocale from 'element-plus/dist/locale/zh-cn'
import elementJaLocale from 'element-plus/lib/locale/lang/ja'
import { getLanguage } from '@/utils/session'

import en from './en'
import zh from './zh'
import ja from './ja'

interface Messages {
  [key: string]: any
}

export const messages: Messages = {
  en: {
    ...en,
    ...elementEnLocale
  },
  zh: {
    ...zh,
    ...elementZnLocale
  },
  ja: {
    ...ja,
    ...elementJaLocale
  }
}

const localData = {
  legacy: false,
  globalInjection: true,
  locale: getLanguage(),
  messages
}

const i18n = createI18n(localData)

export default i18n
